package com.taptech.doufu.ui.view.topicview;

import android.content.Context;

import com.taptech.doufu.constant.HomePageType;
import com.taptech.doufu.constant.UmengEventName;
import com.taptech.doufu.bean.EventBean;
import com.taptech.doufu.util.TMAnalysis;
import com.taptech.doufu.util.TextUtil;

import java.util.HashMap;

public class UmengEventUtil {

    public static void addEvent(Context context, String eventName, EventBean eventBean) {
        if (eventBean == null) {
            return;
        }
        HashMap<String, String> map = new HashMap<>();
        map.put("position", String.valueOf(eventBean.getPosition()));
        map.put("cardType", String.valueOf(eventBean.getCardType()));
        map.put("moreType", String.valueOf(eventBean.getMoreType()));
        map.put("title", eventBean.getTitle());
        TMAnalysis.event(context, eventName,map);
    }

    public static void addRightTopBtnEvent(Context context, EventBean eventBean, String sexType) {
        if (TextUtil.isEmpty(sexType)) {
            return;
        }
        if (eventBean == null) {
            return;
        }
        if ("1".equals(sexType)) {
            addEvent(context,UmengEventName.RAINBOW_CARD_RIGHT_TOP_BTN,eventBean);
        }else if ("3".equals(sexType)){
            addEvent(context,UmengEventName.ROMANCE_CARD_RIGHT_TOP_BTN,eventBean);
        }
    }

    public static void addRightTopBtnEvent(Context context, EventBean eventBean, String sexType,String pageType) {
        if (TextUtil.isEmpty(sexType)) {
            return;
        }
        if (eventBean == null) {
            return;
        }
        if ("1".equals(sexType)) {
            if (HomePageType.COPYRIGHT.equals(pageType)) {
                addEvent(context,UmengEventName.COPYRIGHT_CARD_RIGHT_TOP_BTN,eventBean);
            } else if (HomePageType.RAINBOW_FINISHED.equals(pageType)) {
                addEvent(context,UmengEventName.RAINBOW_FINISHED_CARD_RIGHT_TOP_BTN,eventBean);
            }else{
                addEvent(context,UmengEventName.RAINBOW_CARD_RIGHT_TOP_BTN,eventBean);
            }
        }else if ("3".equals(sexType)){
            addEvent(context,UmengEventName.ROMANCE_CARD_RIGHT_TOP_BTN,eventBean);
        }
    }

    public static void addContentEvent(Context context, EventBean eventBean, String sexType) {
        if (TextUtil.isEmpty(sexType)) {
            return;
        }
        if (eventBean == null) {
            return;
        }
        if ("1".equals(sexType)) {
            addEvent(context,UmengEventName.RAINBOW_FINISHED_CARD_CONTENT,eventBean);
        }else if ("3".equals(sexType)){
            addEvent(context,UmengEventName.ROMANCE_CARD_CONTENT,eventBean);
        }
    }

    public static void addContentEvent(Context context, EventBean eventBean, String sexType,String pageType) {
        if (TextUtil.isEmpty(sexType)) {
            return;
        }
        if (eventBean == null) {
            return;
        }
        if ("1".equals(sexType)) {
            if (HomePageType.COPYRIGHT.equals(pageType)) {
                addEvent(context,UmengEventName.COPYRIGHT_CARD_CONTENT,eventBean);
            } else if (HomePageType.RAINBOW_FINISHED.equals(pageType)) {
                addEvent(context,UmengEventName.RAINBOW_CARD_CONTENT,eventBean);
            }else{
                addEvent(context,UmengEventName.RAINBOW_FINISHED_CARD_CONTENT,eventBean);
            }
        }else if ("3".equals(sexType)){
            addEvent(context,UmengEventName.ROMANCE_CARD_CONTENT,eventBean);
        }
    }
}
